# coding = utf-8

'''
解压缩Lits数据集
'''

import zipfile
import os

def read_zip_data():
    zip_root_path = "F:\Dataset\Liver\LITS17"
    unzip_root_path = "F:\Dataset\Liver\LITS"

    for i in range(131):
        raw_data_path = os.path.join(zip_root_path, "volume-{}.nii.zip".format(i))
        mask_data_path = os.path.join(zip_root_path, "segmentation-{}.nii.zip".format(i))
        raw_data_zip = zipfile.ZipFile(raw_data_path, "r")
        mask_data_zip = zipfile.ZipFile(mask_data_path, "r")

        raw_data_file = raw_data_zip.namelist()[0]
        mask_data_file = mask_data_zip.namelist()[0]

        raw_data_zip.extract(raw_data_file, unzip_root_path)
        mask_data_zip.extract(mask_data_file, unzip_root_path)

        print(raw_data_file)



if __name__ == '__main__':
    read_zip_data()